/*
============================================================================
 Name        : BlockTelOrder.h
 Author      : emoney
 Version     :
 Copyright   : www.emoney.cn
 Description : CBlockTelOrder declaration
============================================================================
*/

#ifndef BLOCKTELORDER_H
#define BLOCKTELORDER_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include "Block.h"
#ifdef __SERIES60_3X__
#include "PhoneCallMaker2.h"
#else
#include "PhoneCallMaker.h"
#endif
#include "Flickable.h"

class CSingleLineTextInput;
/**
*  CBlockTelOrder
* 
*/
class TBrokerMap
{
public:
	TBuf<200> m_strText;
	TBuf<32> m_strPinyin;
	TBuf<32> m_strTel;
};

class CBlockTelOrder : public CBlock,MAnsPhoneCallMakerObserver, MFlickableCallback
{
public:
	~CBlockTelOrder();

	static CBlockTelOrder* NewL(CBaseBlock* bsBack,const TInt &nReqType,const TDesC& aDesMain,const TDesC& aDesMinor);

	static CBlockTelOrder* NewLC(CBaseBlock* bsBack,const TInt &nReqType,const TDesC& aDesMain,const TDesC& aDesMinor);

public:
	//from CBlock
	void OnDraw(CFbsBitGc& g)const;

	void OnKeyEvent(const TInt& keyCode);

	TBool ReadData(const TDesC8& aData);

	void WriteData(TDes8& aBuf);

	TInt GetDataLength();

	TInt16 GetDataType();

	void ChangeScrollPos(TInt nPos);

	void InitPopMenu(const TInt& nType);

	TBool OnMenuEvent(TInt menuId);

	void SizeChanged();

	void OnInput(const TDesC8& strInput);
	
	void OnMouseUp(const TPoint& aPt);
	
	void OnMouseDown(const TPoint& aPt);

	void OnMouseMove(const TPoint& aPt);
	
	void ChangeFocus(TBool aFoucs, const TInt& keyCode);
public:
	// from MFlickableCallback
	virtual TPoint ScrollOffset() const;

	virtual void SetScrollOffset(const TPoint& aOffset);

public: // from MTabbarObserver
	void HandleTabbarCommand(TInt aCommand);

public:
	void StartRoll();

	void StopRoll();

	static TInt OnRoll(TAny* aAny);
	
	void AddBroker(const TBrokerMap& aBroker);

	void CheckEmpty();
	
	void OnInput(const TDesC& strInput);

protected:
	void AddTabs();

	void BeforeDraw(CFbsBitGc& g) const;

private:
	void CheckRoll();

	void SaveBrokers();

	void LoadBrokers();

	void MakeCall();

public:
	virtual void HandleCallHungUpL();
	
private:
	CBlockTelOrder(CBaseBlock* bsBack,const TInt &nReqType,const TDesC& aDesMain,const TDesC& aDesMinor);

	void ConstructL();
	
private:
	TBuf<64> m_strMain;
	TBuf<64> m_strMinor;
	
	TInt16 m_nReqType;
	RArray<TBrokerMap> m_vBroker;
	RArray<TBrokerMap> m_vBrokerMatched;
	TInt m_nCurrent;
	
	mutable CPeriodic*	m_AnimationTimer;	//\x{fffd}\x{fffd}
	mutable TInt m_nX;
	CSingleLineTextInput* m_Input;

	TBuf<32> m_bufDownloading;
	TBuf<32> m_bufNobroker;
	TBuf<32> m_bufAddbroker;
	TBuf<32> m_bufNoInfo;

	TBool	m_bWantSave;
	
#ifdef __SERIES60_3X__
	CPhoneCallMaker2*	m_CallMaker;
#else
	CPhoneCallMaker*	m_CallMaker;
#endif
	
	TInt iOffset;
	TInt iHeight;
	TInt iHighlight;
	CFlickable*		iFlickable;
	TRect			iListRect;

	mutable TInt iStartItem;
	mutable TInt iEndItem;
};

#endif // BLOCKTELORDER_H
